<?php

if(!defined('APP_ROOT_PATH')) 
define('APP_ROOT_PATH',str_replace('system/api_login/qq/redirect_to_login.php','',str_replace('\\','/',__FILE__)));
require_once APP_ROOT_PATH.'system/utils/es_session.php';
es_session::start();
require_once('get_request_token.php');
$appid = $_REQUEST['appid'];
$appkey = $_REQUEST['appkey'];
$callback = urldecode($_REQUEST['callback']);
function redirect_to_login($appid,$appkey,$callback)
{
$redirect = "http://openapi.qzone.qq.com/oauth/qzoneoauth_authorize?oauth_consumer_key=$appid&";
$result = array();
$request_token = get_request_token($appid,$appkey);
parse_str($request_token,$result);
es_session::set('token',$result['oauth_token']);
es_session::set('secret',$result['oauth_token_secret']);
if ($result['oauth_token'] == '')
{
exit;
}
$redirect .= 'oauth_token='.$result['oauth_token'].'&oauth_callback='.rawurlencode($callback);
header("Location:$redirect");
}
redirect_to_login($appid,$appkey,$callback);

?>